'use strict'
const path = require('path')
function resolve(dir) {
	return path.join(__dirname, dir)
}

const port = 8889 // dev port

module.exports = {
	publicPath: './',
	outputDir: 'app',
	assetsDir: 'app',
	lintOnSave: false,
	productionSourceMap: false,
	devServer: {
		port: port,
		open: true,
		overlay: {
			warnings: false,
			errors: true
		},
		proxy: {
			'/API-APP/': {
				//target: 'http://192.168.100.205:8001',
				//target: 'http://103.91.176.99:9060/API-APP/',
				//target: 'http://192.168.105.11:8001',
				target: 'http://192.168.105.65:8001',
				changeOrigin: true,
				pathRewrite: {
					'^/API-APP/': '/'
				}
			},
			'/API-ENTERPRISE-APP/': {
				target: 'http://103.91.179.38:14001',
				//target: 'http://103.91.176.99:9058/API-ENTERPRISE-APP/',
				changeOrigin: true,
				pathRewrite: {
					'^/API-ENTERPRISE-APP/': '/'
				}
			},
			'/API-ENTERPRISE-LEARN/': {
				target: 'http://103.91.179.38:14009',
				//target: 'http://103.91.176.99:9058/API-ENTERPRISE-LEARN/',
				changeOrigin: true,
				pathRewrite: {
					'^/API-ENTERPRISE-LEARN/': '/'
				}
			},
			'/API-ENTERPRISE-BACKEND/': {
				target: 'http://103.91.179.38:14000',
				//target: 'http://103.91.176.99:9058/API-ENTERPRISE-BACKEND/',
				changeOrigin: true,
				pathRewrite: {
					'^/API-ENTERPRISE-BACKEND/': '/'
				}
			},
			'/API-ENTERPRISE-NEWS/': {
				target: 'http://103.91.179.38:14010',
				//target: 'http://103.91.176.99:9058/API-ENTERPRISE-NEWS/',
				changeOrigin: true,
				pathRewrite: {
					'^/API-ENTERPRISE-NEWS/': '/'
				}
			},
			'/API-ENTERPRISE-ACTIVITY/': {
				target: 'http://103.91.179.38:14008',
				//target: 'http://103.91.176.99:9058/API-ENTERPRISE-NEWS/',
				changeOrigin: true,
				pathRewrite: {
					'^/API-ENTERPRISE-ACTIVITY/': '/'
				}
			},
			'/API-DOCUMENT/': {
				target: 'http://103.91.176.99:9060/API-DOCUMENT/',
				changeOrigin: true,
				pathRewrite: {
					'^/API-DOCUMENT/': '/'
				}
			},
			'/API-ENTERPRISE-WELFARE/': {
				target: 'http://192.168.100.202/API-ENTERPRISE-WELFARE/',
				changeOrigin: true,
				pathRewrite: {
					'^/API-ENTERPRISE-WELFARE/': '/'
				}
			}
		}
	},
	chainWebpack: config => {
		config.plugins['delete']('preload') // TODO: need test
		config.plugins['delete']('prefetch') // TODO: need test
		// 修复HMR
		config.resolve.symlinks(true)
	},
	configureWebpack: {
		resolve: {
			alias: {
				'@': resolve('src'),
				vue$: 'vue/dist/vue.esm.js'
			}
		}
	},
	css: {
		loaderOptions: {
			sass: {
				// 根据自己样式文件的位置调整
				data: '@import "@/styles/mixin.scss";'
			}
		}
	}
}
